﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangMayTinh.DataAccessLayer;
using CuaHangMayTinh.BusinessEntities;
using CuaHangMayTinh.Utilities;
using System.Data;

namespace CuaHangMayTinh.BusinessLogicLayer
{
    public class XuatKhoTraHangManager
    {
        private static XuatKhoTraHangDA adapter = null;

        static XuatKhoTraHangManager()
        {
            if (adapter == null)
                adapter = new XuatKhoTraHangDA();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int Insert(XuatKhoTraHangEntity entity)
        {
            try
            {
                return adapter.InsertTS(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return 0;
            }
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="View"></param>
        /// <returns></returns>
        public static DataTable Find_All(bool View)
        {
            try
            {
                return adapter.Find_All(View);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static DataTable GetMaHDMax()
        {
            try
            {
                return adapter.GetMaHDMax();
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

        public static XuatKhoTraHangEntity GetAllInfo_ID(int MaXuatKhoTraHang)
        {
            try
            {
                return adapter.GetAllInfo_ID(MaXuatKhoTraHang);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static List<XuatKhoTraHangEntity> ConvertToList(DataTable dt)
        {
            try
            {
                return adapter.ConvertToList(dt);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return null;
            }
        }

    }
}
